<?php require("../inc/common.inc.php");
$VPPWIFISHANG="5";
$VPPURL="http://weixin.mxsoft.cn/";
?>
<!DOCTYPE >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
if ($actions=="setren"){
	$rentype=intval($rentype);
	//验证来路
	$truepath=preg_replace("/(.+)\/([^\/]+)\/([^\/]+)/is","\\1",'http://'.$HTTP_HOST);
	if ($webdb[weburl]!=$truepath){
		$fun->popmassage("非法访问，系统将返回上一页","","popback");
		exit();
	}
	$mac=trim($mac);
	$Rid=intval($Rid);
	if($Rid==0 or $mac=="" or strlen($mac)!=12){
		$fun->popmassage("非法访问，系统将返回上一页","","popback");
		exit();
	}
	
	if ($rentype==1){
		$mobile=trim($mobile);
		$mac=trim($mac);
		$Rid=intval($Rid);
		$ycode=trim($ycode);
		//是否为空
		if($mobile==""){
			$fun->popmassage("请输入手机号码","","popback");
			exit();
		}
		//验证手机号格式
		if(!eregi("^[0-9]{11,11}$",$mobile)){
			$fun->popmassage("输入手机号码格式错误","","popback");
			exit();
		}
		if($ycode==""){
			$fun->popmassage("请输入手机验证码","","popback");
			exit();
		}

		$getstatus=file_get_contents($VPPWIFIURL."wifirenzheng_mx_get.php?rentype=1&mobile=$mobile&mac=$mac&Rid=$Rid&shang={$VPPWIFISHANG}&yancode=$ycode&sign=".md5($mac."{mx}".$VPPWIFISHANG."{z}".$mobile."{w}".$Rid."{w}".$ycode."{w}"));
		if($getstatus=="1"){
			$fun->popmassage("",$VPPURL,"gotourl");
			exit();
		}
		else{
			$fun->popmassage("手机号码验证失败","","popback");
			exit();
		}
	}
	elseif($rentype==999){
		$mac=trim($mac);
		$Rid=intval($Rid);
		if($mac=="" or $Rid==0){
			$fun->popmassage("非法访问","","popback");
			exit();
		}

		$getstatus=file_get_contents($VPPWIFIURL."wifirenzheng_mx_get.php?rentype=999&mac=$mac&Rid=$Rid&shang={$VPPWIFISHANG}&sign=".md5($mac."{mx}".$VPPWIFISHANG."{z}{w}".$Rid."{w}"));
		if($getstatus=="1"){
			$fun->popmassage("登录验证成功",$VPPURL,"alertgotourl");
			exit();
		}
		else{
			$fun->popmassage("认证失败","","popback");
			exit();
		}
	}
	else{
		$fun->popmassage("非法的认证","","popback");
		exit();
	}
}
?>
<title>阿瓦山寨</title>
<meta name="searchtitle" content="阿瓦山寨">
<meta name="description" content="阿瓦山寨">
<meta name="keywords" content="阿瓦山寨">
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<style type="text/css">
body{padding:0px;margin:0px; background-color:#FFFFFF;}
img{border:0px;}
.sub{width:100%;margin:0 auto;position:relative;}
.sub img{width:100%;}
.bottom123{width:100%;/*position:fixed;bottom:0px;*/}
.input123{padding:0px;margin:0px;width:100%;height:40px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;border:#ccc 1px solid; 
          /*box  x阴影  y阴影  10羽化  阴影颜色  */
box-shadow: 0px 0px 5px #ccc inset;/* inset 向内阴影 */}
.input1231{padding:0px;margin:0px;width:80%;height:40px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;border:#ccc 1px solid; 
          /*box  x阴影  y阴影  10羽化  阴影颜色  */
box-shadow: 0px 0px 5px #ccc inset;/* inset 向内阴影 */}

.input234{width:100%;background:url(images/an.jpg) 0 0 repeat-x;height:40px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px; color:#FFFFFF; line-height:40px; text-align:center;}
.input234 a{color:#fff;line-height:40px; text-align:center;width:100%;height:40px;overflow:hidden;display:block;font-size:12px; text-decoration:none;}

</style>
</head>
<script type="text/javascript" src="../js/jquery_min.js"></script>
<script>
function get_yancode(){
	var mobile = document.form1.mobile.value;
	if (document.form1.mobile.value==""){
		alert("请输入手机号码");
		return false;
	}
	
	var patrn = /(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/; 
	if (!patrn.exec(mobile)) {
		alert ('手机号码格式不正确');
		document.form1.mobile.focus();
		return false;
	}
	
	timedCount();
	$.ajax({
    url: 'wifirenzheng.php?rentype=1&mac=<?php echo $mac;?>&Rid=<?php echo $Rid;?>&mobile='+mobile,
    type: 'GET',
    dataType: 'html',
    timeout:15000,
    error: function(){
        c=Time;
        stopCount();
        document.getElementById('getcode').innerHTML='<a href="javascript:get_yancode();">获取验证码</a>';
        alert('获取验证码失败');
    },
    success: function(html){
        if (html!="1"){	
			c=Time;
			stopCount();
            document.getElementById('getcode').innerHTML='<a href="javascript:get_yancode();">获取验证码</a>';
            alert('获取验证码失败');
        }
    }});
	
}
</script>
<body>
<?php
$ismanyou=file_get_contents($VPPWIFIURL."wifirenzheng_mx_get.php?rentype=99&mac=$mac&Rid=$Rid&shang={$VPPWIFISHANG}&sign=".md5($mac."{mx}".$VPPWIFISHANG."{z}{w}".$Rid."{w}"));
if ($ismanyou=="1"){
?>
<div class="sub"><a href="index.php?actions=setren&rentype=999&mac=<?php echo $mac;?>&Rid=<?php echo $Rid;?>"><img src="images/bg.png" ></a></div>
<?php
}
else{
?>
<div class="sub"><img src="images/bg.png" ></div>
<div class="bottom123">
<form  name="form1" id="form1" action="index.php" method="post" onSubmit="return check_form1()">
  <table width="90%" border="0" align="center" cellpadding="3" cellspacing="0">
    <tr><td colspan="2" style="color:#FF0000; line-height:150%; font-weight:bold;" align="center">免费获取WIFI验证短信</td></tr>
    <tr>
      <td width="66%" height="61"><input name="mobile" id="mobile" type="text" class="input123" placeholder="手机号码"></td>
      <td width="34%"><div class="input234" id="getcode"><a href="javascript:get_yancode();">获取验证码</a></div></td>
    </tr>
    <tr>
      <td><input name="ycode" id="ycode" type="text" class="input123" placeholder="验证码"></td>
      <td><div class="input234"><a href="javascript:document.form1.submit();">开始上网</a></div></td>
    </tr>
  </table>
	<input type="hidden" name="mac" id="mac" value="<?php echo trim($mac);?>">
	<input type="hidden" name="Rid" id="Rid" value="<?php echo trim($Rid);?>">
	<input type="hidden" name="rentype" value="1">
	<input type="hidden" name="actions" value="setren">
</form>

<script>
function check_form1(){
	if (document.form1.mobile.value==""){
		alert("手机号码不能为空");
		document.form1.mobile.focus();
		return false;
	}
	if (document.form1.ycode.value==""){
		alert("验证码不能为空");
		document.form1.ycode.focus();
		return false;
	}
}

    var Time=30,t;
    var c=Time
    function timedCount(){
        document.getElementById('getcode').innerHTML="请稍等(" + c + ")";
        c=c-1;
        t=setTimeout("timedCount()",1000)
        if(c<0){
            c=Time;
            stopCount();
            document.getElementById('getcode').innerHTML='<a href="javascript:get_yancode();">获取验证码</a>';
        }
    }
	
    function stopCount(){
        clearTimeout(t);
    }
</script>
</div>
<?php
}
?>
</body>
</html>
